from doctest import master

'''一个经典的GUI程序的写法，使用面向对象的方法'''
from tkinter import *
from tkinter import messagebox

class Application(Frame):
     def __init__(self,  master=None):
         super().__init__(master)
         self.master = master
         self.pack()
         self.createWidgets()

     def createWidgets(self):
         '''创建组件'''
         self.bth01 = Button(self)
         self.bth01["text"] = "点击送花"
         self.bth01.pack()
         self.bth01["command"] = self.songhua
         '''创建一个退出按钮'''
         self.bthquit = Button(self , text="退出", command=root.destroy)
         self.bthquit.pack()
     def songhua(self):
         messagebox.showinfo("送花","送你99朵玫瑰花")

if __name__ == '__main__':
   root = Tk()
   root.geometry("400x100+200+300")
   root.title("一个经典GUI程序测试")
   app = Application(master=root)
   root.mainloop()